using System.ComponentModel.DataAnnotations;

namespace Hospital.Domain
{
    /// <summary>
    /// 医生实体类
    /// </summary>
    public class Doctor
    {
        /// <summary>
        /// 主键Id
        /// </summary>
        [Key]
        public int Id { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; } 

        /// <summary>
        /// 性别
        /// </summary>
        public string Gender { get; set; } 

        /// <summary>
        /// 注册时间
        /// </summary>
        public DateTime RegistrationTime { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        public string? Phone { get; set; }

        /// <summary>
        /// 医院
        /// </summary>
        public string? Hospital { get; set; }

        /// <summary>
        /// 科室
        /// </summary>
        public string? Department { get; set; }

        /// <summary>
        /// 职称
        /// </summary>
        public string? Title { get; set; }

        /// <summary>
        /// 银行卡号
        /// </summary>
        public string? BankCardNumber { get; set; }

        /// <summary>
        /// 特长
        /// </summary>
        public string? Specialty { get; set; }

        /// <summary>
        /// 简介
        /// </summary>
        public string? Introduction { get; set; }

        /// <summary>
        /// 证书
        /// </summary>
        public string? Certificates { get; set; }

        /// <summary>
        /// 证件照
        /// </summary>
        public string? Photo { get; set; }

        /// <summary>
        /// 审核状态
        /// </summary>
        public string? AuditStatus { get; set; }

        /// <summary>
        /// 服务审核
        /// </summary>
        public string? ServiceAudit { get; set; }

        /// <summary>
        /// 删除标记
        /// </summary>
        public bool IsDeleted { get; set; } 

        /// <summary>
        /// 导航属性：服务审核工作流
        /// </summary>
        public virtual ICollection<ServiceAuditWorkflow> ServiceAuditWorkflows { get; set; } = new List<ServiceAuditWorkflow>();

        /// <summary>
        /// 获取最新的服务审核工作流
        /// </summary>
        public ServiceAuditWorkflow? GetLatestServiceAuditWorkflow()
        {
            return ServiceAuditWorkflows
                .Where(w => !w.IsDeleted)
                .OrderByDescending(w => w.CreatedTime)
                .FirstOrDefault();
        }

        /// <summary>
        /// 获取当前服务审核状态
        /// </summary>
        public string GetCurrentServiceAuditStatus()
        {
            var latestWorkflow = GetLatestServiceAuditWorkflow();
            if (latestWorkflow == null)
                return "待审核";

            return WorkflowService.GetWorkflowStatusDescription(latestWorkflow);
        }
    }
} 